package org.cnbi.utils.sort;

import java.util.Comparator;

import org.cnbi.utils.pojo.indicator.IndicatorParamsBean;

public class ReverseSort implements Comparator<Object> {
	
	private String type = "asc";//desc反向排序
	
	private String pro;
	
	public ReverseSort(String pro,String type){
		this.type = type;
	    this.pro = pro;
	}
	
	public ReverseSort(){}

	public String getType() {
		return type;
	}



	public void setType(String type) {
		this.type = type;
	}



	public String getPro() {
		return pro;
	}



	public void setPro(String pro) {
		this.pro = pro;
	}



	@Override
	public int compare(Object beanOne, Object beanTwo) {
		int result  = 0;
		if(beanOne instanceof IndicatorParamsBean){
			IndicatorParamsBean o1 = (IndicatorParamsBean)beanOne;
			IndicatorParamsBean o2 = (IndicatorParamsBean)beanTwo;
			Integer len1 = o1.getName().length(),len2 = o2.getName().length();
		   result  = len1.compareTo(len2);

		}
		if(this.type.equals("desc")){
			result = -result;
		}
		return result;
	}

	
	
	


}
